﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.Settings;

namespace PMS.Data.EntityMap.Common
{
    /// <summary>
    /// Represents a Settings mapping configuration
    /// </summary>
    public partial class SettingsMap : PMSEntityTypeConfiguration<Setting>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<Setting> builder)
        {
            builder.ToTable("sys_settings");
            builder.HasKey(setting => setting.Id);

            builder.Property(setting => setting.Name).HasMaxLength(200).IsRequired();
            builder.Property(setting => setting.Value).HasMaxLength(2000).IsRequired();

            builder.Ignore(setting => setting.IsActive);
            builder.Ignore(setting => setting.CreatedOnTimeUtc);
            builder.Ignore(setting => setting.UpdatedOnTimeUtc);
            base.Configure(builder);
        }

        #endregion
    }
}
